package com.qlm.view;

import java.io.Serializable;


/**
 * 信息传递类
 * @author yancy
 *
 */
public class ResultMessage implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int state;				//传递状态
	private String message;	//传递信息
	private Object data;			//传递数据
	
	/*
     * 状态描述
     */
    private String stateDescStr;

	public String getStateDescStr() {
		stateDescStr = "";
		for (StateDesc sd : StateDesc.values()) {
			if (sd.value.equals(state)) {
				stateDescStr = sd.toString();
				break;
			}
		}
		return stateDescStr;
	}

	public static enum StateDesc {
		FAIL(0), SUCCESS(1);
		private Integer value;

		private StateDesc(Integer value) {
			this.value = value;
		}
		public Integer getValue() {
			return value;
		}
	}
	
	public ResultMessage(){
		super();
	}
	
	public ResultMessage(int state,String message,Object data){
		super();
		this.state = state;
		this.message = message;
		this.data = data;
	}
	
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	
	public static ResultMessage setAllMessage(int state,String message,Object data){
		return new ResultMessage(state, message, data);
	}
	
	public static ResultMessage setAllMessage(int state,String message){
		return new ResultMessage(state, message, null);
	}

	@Override
	public String toString() {
		return "ResultMessage [stateDescStr=" + stateDescStr + ", message=" + message
				+ ", data=" + data + "]";
	}
}
